import dayjs from "dayjs"
App({
  /**
   * 当小程序初始化完成时，会触发 onLaunch（全局只触发一次）
   */
  globData: {
    start: {},
    end: {},
    userStart: [],
    userInfo: {},
    isLogin: false,
    roomOrder: {
      price: 0,
      info: {},
    },
    dinnerInfo: {},
  },
  onLaunch: function () {
    const systemInfo = wx.getSystemInfoSync()
    const statusBarHeight = systemInfo.statusBarHeight
    const buttonTop = wx.getMenuButtonBoundingClientRect().top
    const buttonHeight = wx.getMenuButtonBoundingClientRect().height
    const navBarHeight = (buttonTop - statusBarHeight) * 2 + buttonHeight
    this.globData.start = dayjs()
    this.globData.end = dayjs().add(1, "day")
    wx.setStorageSync("statusBarHeight", statusBarHeight)
    wx.setStorageSync("navBarHeight", navBarHeight)
  },

  /**
   * 当小程序启动，或从后台进入前台显示，会触发 onShow
   */
  onShow: function (options) {},

  /**
   * 当小程序从前台进入后台，会触发 onHide
   */
  onHide: function () {},

  /**
   * 当小程序发生脚本错误，或者 api 调用失败时，会触发 onError 并带上错误信息
   */
  onError: function (msg) {},
})
